package com.cyt.sys.service.impl;

import com.cyt.sys.dao.SysUserPostDao;
import com.cyt.sys.model.po.SysUserPost;
import com.cyt.sys.service.SysUserPostService;
import com.github.pagehelper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 *@Author: dingxu
 *@Date: 2018-11-16 11:54
 *@Description:基础角色岗位关联类
 */
@Service("baseUserPostService")
public class SysUserPostServiceImpl extends BaseServiceImpl<SysUserPost> implements SysUserPostService {

    @Resource
    private SysUserPostDao sysUserPostDao;

    @Autowired
    public void setBaseDao(SysUserPostDao sysUserPostDao) {
        this.baseDao = sysUserPostDao;
    }


    @Override
    public int deleteByUserId(String userId) {
        return sysUserPostDao.deleteByUserId(userId);
    }

    @Override
    public List<SysUserPost> selectList(SysUserPost sysUserPost) {
        Example example = new Example(SysUserPost.class);
        Example.Criteria criteria = example.createCriteria();
        if(sysUserPost !=null){
            if(StringUtil.isNotEmpty(sysUserPost.getUserId())){
                criteria.andEqualTo("userId", sysUserPost.getPostId());
            }
        }
        return  sysUserPostDao.selectByExample(example);
    }
}
